package com.platform.service.impl;

import com.platform.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.platform.dao.AccountSnapshotEnergyDao;
import com.platform.entity.AccountSnapshotEnergyEntity;
import com.platform.service.AccountSnapshotEnergyService;

/**
 * 能量值发放记录表Service实现类
 *
 * @author liweihai
 * @email liweihai12345@sina.com
 * @date 2019-05-28 15:18:07
 */
@Service("accountSnapshotEnergyService")
public class AccountSnapshotEnergyServiceImpl implements AccountSnapshotEnergyService {
    @Autowired
    private AccountSnapshotEnergyDao accountSnapshotEnergyDao;

    @Override
    public AccountSnapshotEnergyEntity queryObject(Integer id) {
        return accountSnapshotEnergyDao.queryObject(id);
    }

    @Override
    public List<AccountSnapshotEnergyEntity> queryList(Map<String, Object> map) {
        return accountSnapshotEnergyDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return accountSnapshotEnergyDao.queryTotal(map);
    }

    @Override
    public int save(AccountSnapshotEnergyEntity accountSnapshotEnergy) {
        return accountSnapshotEnergyDao.save(accountSnapshotEnergy);
    }

    @Override
    public int update(AccountSnapshotEnergyEntity accountSnapshotEnergy) {
        return accountSnapshotEnergyDao.update(accountSnapshotEnergy);
    }

    @Override
    public int delete(Integer id) {
        return accountSnapshotEnergyDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        return accountSnapshotEnergyDao.deleteBatch(ids);
    }

    @Override
    public Map<String, Object> createEnergyStatics() {
        System.out.println("进入定时任务");
        return accountSnapshotEnergyDao.createEnergyStatics();
    }

    @Override
    public BigDecimal queryToDayTeam() {
        return accountSnapshotEnergyDao.queryToDayTeam();
    }

    @Override
    public BigDecimal queryToDayTeamSportEnergy() {
        Map<String,Object> param = new HashMap<String, Object>();
        String today = DateUtils.format(new Date());
        Date tomorrow = DateUtils.minusDateForDay(today, 1);
        param.put("today", today);
        param.put("tomorrow",tomorrow);
        return accountSnapshotEnergyDao.queryToDayTeamSportEnergy(param);
    }

    @Override
    public List<Map<String, Object>> createEnergyStaticsList() {
        return accountSnapshotEnergyDao.createEnergyStaticsList();
    }

    /**
     * 能量值总量
     * @return
     */
    @Override
    public BigDecimal queryTotalEnergyDetail() {
        return accountSnapshotEnergyDao.queryTotalEnergyDetail();
    }
}
